package com.shuqi.controller;

import android.content.Context;

import com.shuqi.interfaces.IEventListener;
import com.shuqi.model.LoginAccountModel;

public class LoginAcountController extends ControllerBase {

    public static final int LOGIN_ACCOUNT_DEFAULT = 209;

    public static final int LOGIN_ACCOUNT_SINA = 210;

    private LoginAccountModel mLoginAccountmodel; // login的model

    public LoginAcountController(Context context) {
        mLoginAccountmodel = new LoginAccountModel(context);
    }

    @Override
    public void addEventListener(IEventListener listener) {
        mLoginAccountmodel.addEventListener(listener);
    }

    @Override
    public void handle(int eventType, Object... objs) {
        if (eventType == LOGIN_ACCOUNT_DEFAULT) {
            mLoginAccountmodel.loadData(objs);
        } else if (eventType == LOGIN_ACCOUNT_SINA) {
            mLoginAccountmodel.loginBySina(String.valueOf(objs[0]));
        }


    }

    @Override
    public void onDestroy() {
        if (mLoginAccountmodel != null) {
            mLoginAccountmodel.onDestroy();
        }

    }

}
